import os
import sys
import json

request_repo_dir='/home/gxw/Public/zz_static_project'
our_repo_dir='./'
remote_ip='222.20.94.23'
port=22215
user='gxw'


content=[]

if __name__ == '__main__':
    assert len(sys.argv)>=2
    if len(sys.argv)==2:
        local_folder=sys.argv[1]
        remote_folder=local_folder
    else:
        local_folder,remote_folder=sys.argv[1],sys.argv[2]
    
    local_folder=os.path.join(our_repo_dir,local_folder)
    remote_folder=os.path.join(request_repo_dir,remote_folder)
    
    if os.path.exists(local_folder):
        if len(os.listdir(local_folder))>0:
            print(f'{local_folder} is not empty!')
            sys.exit(0)
    
    else:
        os.makedirs(local_folder)
    
    
    cmd=f'scp -P {port} -r {user}@{remote_ip}:{remote_folder} {local_folder}'
    print(cmd)
    os.system(cmd)
    

# python test/sync_test.py preprocessed_data/addon_test

# mods/addon_test
# preprocessed_data/addon_test